package com.gaogzhen.intro.commonMethod;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j(topic = "cm.CMDaemon")
public class CMDaemon {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while (true) {
                if (Thread.currentThread().isInterrupted()) break;
            }
            // 正常情况不会执行
            log.debug("守护线程执行结束...");
        }, "t1");
        t1.setDaemon(true);
        t1.start();
        TimeUnit.SECONDS.sleep(1);
        log.debug("主线程执行结束...");
    }
}
